package onlinebanking.client.gui;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class AccountBalancePanel extends javax.swing.JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel accountBalanceHeader;
	private JLabel accountBalance;
	private JLabel accountNo;

	private ClientPanel parent;
	
	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.getContentPane().add(new AccountBalancePanel());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
	public AccountBalancePanel() {
		super();
		this.parent = null;
		initGUI();
	}
	
	public AccountBalancePanel(ClientPanel parent) {
		super();
		this.parent = parent;
		initGUI();
		sendCommand();
	}
	
	private void initGUI() {
		try {
			this.setPreferredSize(new java.awt.Dimension(526, 400));
			this.setLayout(null);
			{
				accountBalanceHeader = new JLabel();
				this.add(accountBalanceHeader);
				accountBalanceHeader.setText("ACCOUNT BALANCE");
				accountBalanceHeader.setBounds(12, 12, 502, 31);
				accountBalanceHeader.setFont(new java.awt.Font("Arial Black",1,20));
			}
			{
				accountBalance = new JLabel();
				this.add(accountBalance);
				accountBalance.setText("Waiting for server response");
				accountBalance.setBounds(100, 209, 305, 68);
				accountBalance.setFont(new java.awt.Font("Tahoma",0,16));
			}
			{
				accountNo = new JLabel();
				this.add(accountNo);
				accountNo.setText("");
				accountNo.setFont(new java.awt.Font("Tahoma",0,16));
				accountNo.setBounds(100, 125, 305, 40);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void setDisplayAccount(String displayAccountnoString){
		accountNo.setText(displayAccountnoString);
	}
	
	public void setDisplayBalance(String displaybalanceString){
		accountBalance.setText(displaybalanceString);
	}
	
	public void sendCommand(){
		System.out.println("Sending Command");//TODO:
		parent.getSimpleClient().inquireBalance();
	}

}
